<?php

class conversatorioActions extends sfActions {

    public function preExecute()
    {
         $this->getUser()->setAttribute('s_menu', 'conversatorio');
    }

           public function executeVeri(sfWebRequest $request){
           $c=new Criteria();
           $c->add(NoticiasPeer::ID_CAT,2);
           $c->add(NoticiasPeer::DATE, date("Y-m-d"), Criteria::GREATER_EQUAL);
           $cont=NoticiasPeer::doCount($c);
               if($cont>0 ){

                    $this->redirect('@conversatorio_active');
               }
               else{
                    $this->redirect('@conversatorio_active');
               }
       }

    
    public function executeActive(sfWebRequest $request){
        $c = new Criteria();
        $events = array();

        $c->clear();
        $c->add(NoticiasPeer::DATE, date("Y-m-d"), Criteria::GREATER_EQUAL);
        $c->add(NoticiasPeer::ENABLED, 1);
        $c->add(NoticiasPeer::ID_CAT, 2);
        $c->addAscendingOrderByColumn(NoticiasPeer::DATE);

      
        $pager = new sfPropelPager('Noticias', 14);
        $pager->setCriteria($c);
        $pager->setPage($request->getParameter('page', 1));
        $pager->init();
        $this->pager = $pager;

        $maxpag=$pager->getMaxPerPage();
        $this->max=$maxpag;
        $pagina=$request->getParameter('page',1);
        $this->pagina=$pagina;

    }

    public function executePast(sfWebRequest $request){
        $c = new Criteria();
        $events = array();

        $c->clear();
        $c->add(NoticiasPeer::DATE, date("Y-m-d"), Criteria::LESS_THAN);
        $c->add(NoticiasPeer::ENABLED, 1);
        $c->add(NoticiasPeer::ID_CAT, 2);
        $c->addAscendingOrderByColumn(NoticiasPeer::DATE);

        $pager = new sfPropelPager('Noticias',14);
        $pager->setCriteria($c);
        $pager->setPage($request->getParameter('page', 1));
        $pager->init();
        $this->pager = $pager;

        $maxpag=$pager->getMaxPerPage();
        $this->max=$maxpag;
        $pagina=$request->getParameter('page',1);
        $this->pagina=$pagina;
    }

    public function executeDetail(sfWebRequest $request){
        $id = $request->getParameter('id');


        $c = new Criteria();
        $c->add(NoticiasPeer::ID,$id);
        $conversat = NoticiasPeer::doSelectOne($c);
       if(!is_object($conversat)){
            $this->forward404();
        }

        $this->conversatorio = $conversat;
    }

}